/* 
 *  Copyright 2012 CodeMagi, Inc.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.codemagi.servlets.model;

import java.io.Serializable;

/**
 * Extends Node to model an address.
 *
 * @version 1.0
 * @author August Detlefsen for CodeMagi, Inc.
 */
public class Address extends com.codemagi.servlets.model.Node implements Serializable {

    protected String address1;
    protected String address2;
    protected String address3;
    protected String city;
    protected String state;
    protected String zipCode;
    protected String country;


    //CONSTRUCTORS -----------------------------------------------

    /**
     * Default no-arg constructor
     */
    public Address() {
	//no-op
    }

    /**
     * Create a new Address using the values from the passed Address as defaults
     */ 
    public Address(Address defaults) {
	address1 = defaults.getAddress1();
	address2 = defaults.getAddress2();
	address3 = defaults.getAddress3();
	city     = defaults.getCity();
	state    = defaults.getState();
	zipCode  = defaults.getZipCode();
	country  = defaults.getCountry();

	setTerms(defaults.getTerms());
    }


    //GETTERS AND SETTERS ----------------------------------------

    public void setAddress1(String newValue) {
        address1 = newValue;
    }

    public String getAddress1() {
        return address1;
    }

    public void setAddress2(String newValue) {
        address2 = newValue;
    }

    public String getAddress2() {
        return address2;
    }

    public void setAddress3(String newValue) {
        address3 = newValue;
    }

    public String getAddress3() {
        return address3;
    }

    public void setCity(String newValue) {
        city = newValue;
    }

    public String getCity() {
        return city;
    }

    public void setState(String newValue) {
        state = newValue;
    }

    public String getState() {
        return state;
    }

    public void setZipCode(String newValue) {
        zipCode = newValue;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setCountry(String newValue) {
        country = newValue;
    }

    public String getCountry() {
        return country;
    }


    //SPECIAL GETTERS AND SETTERS ------------------------------------------

    /**                                                                                                                    
     * Sets the address fields (address1, address2, etc) to match the passed building                                   
     */
    public void setAddress(Address newAddress) {
        setAddress1(newAddress.getAddress1());
        setAddress2(newAddress.getAddress2());
        setAddress3(newAddress.getAddress3());
        setCity(newAddress.getCity());
        setState(newAddress.getState());
        setZipCode(newAddress.getZipCode());
        setCountry(newAddress.getCountry());

        //NOTE: If we start attaching taxonomy terms to campuses explicitly this will have to be revisisted                       
        setTerms(newAddress.getTerms());
    }

}
